<?php
namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Library\Crypt;

class CarInfoController extends Controller {
    public function getCarWf(Request $request) {
        $data = $request->input('data');
        if(isset($data['hphm']) && empty($data['hphm'])) {
            return $this->ajax(false, '车牌号不能为空');
        }
        if(isset($data['hpzl']) && empty($data['hpzl'])) {
            return $this->ajax(false, '号牌种类不能为空');
        }
        if(isset($data['clsbdh']) && empty($data['clsbdh'])) {
            return $this->ajax(false, '车辆识别号后六位不能为空');
        }

        $des = new Crypt();
        $res = $des->get_car_wf($data['hphm'], $data['hpzl'], $data['clsbdh']);
        if(isset($res['status']) && $res['status']) {
            return $this->ajax('true', $res['data']);
        }
        return $this->ajax('false', '请核信息是否有误在查询');
    }

    public function getJsrWf(Request $request) {
        $data = $request->input('data');
        if(isset($data['sfzhm']) && empty($data['sfzhm'])) {
            return $this->ajax(false, '驾驶证号不能为空');
        }
        if(isset($data['dabh']) && empty($data['dabh'])) {
            return $this->ajax(false, '档案编号不能为空');
        }
        $des = new Crypt();
        $res = $des->get_jsr_wf($data['sfzhm'], $data['dabh']);
        if(isset($res['status']) && $res['status']) {
            return $this->ajax('true', $res['data']);
        }
        return $this->ajax('false', '请核信息是否有误在查询');
    }

    public function getJsrInfo(Request $request) {
        $data = $request->input('data');
        if(isset($data['sfzhm']) && empty($data['sfzhm'])) {
            return $this->ajax(false, '驾驶证号不能为空');
        }
        if(isset($data['dabh']) && empty($data['dabh'])) {
            return $this->ajax(false, '档案编号不能为空');
        }
        $des = new Crypt();
        $res = $des->get_jsr_info($data['sfzhm'], $data['dabh']);
        if(isset($res['status']) && $res['status']) {
            return $this->ajax('true', $res['data']);
        }
        return $this->ajax('false', '请核信息是否有误在查询');
    }

}
